package com.leo.quartz.service;

import com.leo.quartz.common.util.UserTest;
import com.leo.quartz.entity.GroupPO;
import com.leo.quartz.entity.UserPO;
import com.leo.quartz.repository.BatchDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author liusl
 * @version 1.0
 * @date 2018/12/24 21:29
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private BatchDao batchDao;
    @Override

    public void insertTest() {
      List<UserTest> userTestList = new ArrayList<>();
        UserPO user ;
        GroupPO group;
        UserTest test;
        for(int i=0;i<10000;i++){
            test = new UserTest();
            user = new UserPO();
            user.setAge(i);
            user.setName(String.valueOf(i));
            group = new GroupPO();
            group.setDesc("iiikdkkkd");
            test.setGroupPO(group);
            test.setUser(user);
            userTestList.add(test);
        }
        long start  = System.currentTimeMillis();
        System.out.println("开始时间:" + start);
        batchDao.batchInsert(userTestList);
        System.out.println("结束时间:" + System.currentTimeMillis());
        System.out.println("结束时间:" + (System.currentTimeMillis()-start)/1000 + " 秒");
    }
}
